home *** CD-ROM | disk | FTP | other *** search
/ Aminet 15 / Aminet 15 - Nov 1996.iso / Aminet / comm / www / ALynx.lha / ALynx / goodies / copystripper.rexx next >
OS/2 REXX Batch file  |  1995-07-20  |  2KB  |  86 lines

  1. /*
  2.  *
  3.  * Subject:
  4.  * ========
  5.  *   ALynx copy stripper for DOWNLOADER: option
  6.  *
  7.  * Problem:
  8.  * ========
  9.  *   Since the DOWNLOADER: option in Lynx.cfg only accepts
  10.  *   two placeholders ("%s") whereas the first one stands
  11.  *   for the sourcefile with a name like "T:L1285968800.html"
  12.  *   and the second for the filename supplied by the user.
  13.  *   The problem arises from the fact that the second place
  14.  *   holder will be quoted. Ex.: user supplied 'FOOBAR.lha'
  15.  *   the command will be filled as:
  16.  *
  17.  *   copy quiet T:L1285968800.html "FOOBAR.lha" >NIL:
  18.  *
  19.  *   This is a problem, if someone wants to set up different
  20.  *   pathes. Defining something like
  21.  *
  22.  *   DOWNLOADER:Save to SYS\:Tools/:copy quiet %s SYS:Tools/%s >NIL\::TRUE
  23.  *
  24.  *   would result in
  25.  *
  26.  *   copy quiet T:L1285968800.html SYS:Tools/"FOOBAR.lha" >NIL:
  27.  *
  28.  *   which would create a filename with the quote-chars ('"') surrounded.
  29.  *
  30.  * Solution:
  31.  * =========
  32.  *   Define a new DOWNLOADER: entry which calls copystripper.rexx
  33.  *   (Here: saves to ARC:tmp/ directory)
  34.  *
  35.  *   DOWNLOADER:Save to ARC\:tmp/:rx goodies/copystripper.rexx %s %s ARC\:tmp/ >NIL\::TRUE
  36.  *
  37.  * Arguments for copystripper.rexx:
  38.  *
  39.  *   copystripper FROM_NAME DESTINATION_NAME  DESTINATION_DIRECTORY
  40.  *                ^         ^                 ^
  41.  *                |         |                 |
  42.  *                |         |                 +-- supplied by DOWNLOADER: [lynx.cfg]
  43.  *                |         |
  44.  *                |         +-- supplied by second %s (quoted) [Userinput]
  45.  *                |
  46.  *                +-- supplied by first %s [ALynx]
  47.  *
  48.  * Author:
  49.  * =======
  50.  *   Peter Marquardt, wwwutz@tfh-berlin.de || marquardt_p@rz-berlin.de
  51.  *
  52.  * Status:
  53.  * =======
  54.  *   See SUCKS license 8)
  55.  */
  56.  
  57. address arexx
  58.  
  59. parse arg fromname toname todirectory .
  60.  
  61. /*
  62.  * strip quotes
  63.  */
  64.  
  65. tonew = strip(toname,B,'"')
  66.  
  67. /*
  68.  * strip other chars which might slip through the primitive 
  69.  * ALynx filename-security.
  70.  */
  71.  
  72. tonew = compress(tonew,"/:`'[]#?()|")
  73.  
  74. /* create new destinationpath with quotes */
  75. dest  = '"'todirectory||tonew'"'
  76.  
  77. /* create new commandline */
  78. cmd = "COPY QUIET "fromname" TO "dest" >NIL:"
  79.  
  80. /* copy the file */
  81. address command cmd
  82. exit
  83.  
  84. /* Remember: Trivial problems require HUGE scripts 8) */
  85.  
  86.